#ifndef LOG_CC
#define LOG_CC
#include<string>
#include<fstream>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
#include<map>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include "def.hpp"
#include "utils.hpp"
#include "log.hpp"

using namespace std;

namespace Puza{
  PuzaLogger* PuzaLogger::m_pInstance = NULL;

  PuzaLogger* PuzaLogger::Instance()
  {
    if (!m_pInstance)   // Only allow one instance of class to be generated.
      m_pInstance = new PuzaLogger;
    return m_pInstance;
  }

  PuzaLogger::PuzaLogger(){
    log_file_name = PuzaDEF::Instance()->OUTPUT_FILE_NAME + ".log";
  }

  string PuzaLogger::GetCurrentTime(){
    time_t rawtime;
    time(&rawtime);
    return ctime(&rawtime);
  }

  void PuzaLogger::PutString(string s){
    LogFile.open(log_file_name.c_str(), ios::out | ios::app);
    LogFile << s << " " << GetCurrentTime();
    LogFile.close();
  }

  void PuzaLogger::Start(){
    LogFile.open(log_file_name.c_str());
    LogFile.close();
    PutString("Starting Puza Matrix.");
  }

  void PuzaLogger::End(){
    PutString("Completed.");
  }
};

#endif
